package server

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"go-web-admin/logger"
)

type ServerConfig struct {
	Host        string `mapstructure:"host"`
	Port        string `mapstructure:"port"`
	ContextPath string `mapstructure:"context_path"`
	Mode        string `mapstructure:"mode"`
}

// Run 启动服务
func Run(config ServerConfig, router *gin.Engine) {

	addr := fmt.Sprintf("%s:%s", config.Host, config.Port)

	err := router.Run(addr)
	if err != nil {
		logger.Log.Errorf("服务启动失败...%s", err.Error())
		return
	}

	logger.Log.Infof("服务启动成功: %s", addr)
}
